﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VicMessenger.DB;

namespace VicMessenger.DAL
{
    public class CustomFieldTemplateDAL
    {
        public static List<proc_CustomeFieldTemplate_SelectResult> GetCustomFieldTemplate(int? prmCampaignID)
        {
            try
            {
                using (CustomeFieldTemplateDataContext db = new CustomeFieldTemplateDataContext())
                {
                    return db.proc_CustomeFieldTemplate_Select(prmCampaignID).ToList();
                }
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static int? InsertUpdateCustomFieldTemplate(proc_CustomeFieldTemplate_SelectResult prmTemplate)
        {
            try
            {
                int? retCustomFieldTemplateID = 0;
                using (CustomeFieldTemplateDataContext db = new CustomeFieldTemplateDataContext())
                {
                    db.proc_CustomeFieldTemplate_InsertUpdate(prmTemplate.CustomeFieldTemplateID,
                                                              prmTemplate.CampaignID,
                                                              prmTemplate.FieldName,
                                                              prmTemplate.RealFieldName,
                                                              prmTemplate.Active,
                                                              ref retCustomFieldTemplateID);



                    return retCustomFieldTemplateID;
                }
            }
            catch (Exception)
            {
                return 0;
            }
        }
    }
}
